global input "Q:\dc1prhcmsas01\PU2\data - sas"
global temp "Q:\dc1prhcmsas01\PU2\temp_stata_wr"
global log "Q:\dc1prhcmsas01\PU2\Log - Stata WR"
global output "Q:\dc1prhcmsas01\PU2\data_stata_wr"
global graphs "Q:\dc1prhcmsas01\PU2\graphs_stata_wr"
global tables "Q:\dc1prhcmsas01\PU2\tables_stata_wr"

cd "Q:\dc1prhcmsas01\PU2\Code - Stata WR"
set scheme plotplain
graph set window fontface "Times New Roman"

capture log close
log using "$log/11_plot_rd_hires", replace

***********************************************************
*Fig C1
***********************************************************
cap program drop plot_est
program define plot_est 
args name ytitle ylabel
	preserve
	
	*Save estimates
	use "$output/`name'_estimates.dta", clear
	
	*Plot estimates
	graph twoway (scatter beta bin_reg if bin_reg>=820 & bin_reg<=1020, lc(black) mcolor(black) legend(off)) ///
		(rcap ub lb bin_reg if bin_reg>=820 & bin_reg<=1020, color(black) legend(off)) ///
		(line predicted bin_reg if bin_reg>=820 & bin_reg<=1020, legend(off)), ///
		xline(913) xtitle("Weekly Base Pay at Hire") xlabel(820(40)1020) ///
		ytitle(`ytitle') ylabel(`ylabel') legend(off)
	graph export "$graphs/`name'.eps", replace
	graph export "$graphs/`name'.jpg", replace	
	
	restore
end 


	foreach spec in pre post {
	plot_est figc1_raw_base_rd_`spec' "Weekly Base Pay at Previous Job" 500(100)1100
	plot_est figc1_raw_diff_base_rd_`spec' "% Change in Weekly Base Pay from Previous Job"
	plot_est figc1_raw_months_diff_rd_`spec' "Months Since Previous Job" 
	plot_est figc1_raw_observe_rd_`spec' "Probability Observe Any Previous Job" 
	plot_est figc1_raw_base_future_rd_`spec' "Weekly Base Pay 18 Months After Hire" 
	plot_est figc1_raw_wage_growth_rd_`spec' "% Change in Weekly Base Pay 18 Months After Hire" 
	plot_est figc1_raw_separation_rd_`spec' "Probability of Separation 18 Months After Hire" 
	}


***********************************************************
*Fig C2
***********************************************************
cap program drop plot_est_time
program define plot_est_time
args name ytitle ylabel

	*Save estimates
	use "$output/`name'_estimates.dta", clear
	keep if spec=="One-Slope"
	
	*Label each month for graph
	label define time_lab -12 "May 2015" -11 "Jun 2015" -10 "Jul 2015" -9 "Aug 2015" -8 "Sep 2015" -7 "Oct 2015" ///
		-6 "Nov 2015" -5 "Dec 2015" -4 "Jan 2016" -3 "Feb 2016" -2 "Mar 2016" -1 "Apr 2016" ///
		0 "May 2016" 1 "Jun 2016" 2 "Jul 2016" 3 "Aug 2016" 4 "Sep 2016" 5 "Oct 2016" 6 ///
		"Nov 2016" 7 "Dec 2016" 8 "Jan 2017" 9 "Feb 2017" 10 "Mar 2017" 11 "Apr 2017" ///
		12 "May 2017" 13 "Jun 2017" 14 "Jul 2017" 15 "Aug 2017" 16 "Sep 2017" 17 "Oct 2017" ///
		18 "Nov 2017" 19 "Dec 2017" 20 "Jan 2018" 21 "Feb 2018" 22 "Mar 2018" 23 "Apr 2018" ///
		24 "May 2018", replace
	label values event_time time_lab 
	
	drop if event_time>=24
	sum event_time 
	*Plot estimates
	graph twoway (connect beta event_time, lc(black) mcolor(black) legend(off)) (rcap ub lb event_time, color(black) legend(off)) , ///
		xline(0 7) xtitle("Month") xlabel(-12(3)`r(max)', valuelabel angle(45)) ///
		yline(0) ytitle(`ytitle') ylabel(`ylabel') legend(off)
	graph export "$graphs/`name'.eps", replace
	graph export "$graphs/`name'.jpg", replace	
end 

	plot_est_time figc2_base_rd_time "Discontinuity in Base Pay at Previous Job" 
	plot_est_time figc2_log_base_rd_time "Discontinuity in Log Base Pay at Previous Job" 
	plot_est_time figc2_diff_base_rd_time "Discontinuity in % Change in Base Pay from Previous Job"
	plot_est_time figc2_months_diff_rd_time "Discontinuity in Months Since Previous Job" 
	plot_est_time figc2_observe_rd_time "Discontinuity in Probability Observe Any Previous Job" 
	plot_est_time figc2_base_future_rd_time "Discontinuity in Base Pay 18 Months After Hire" 
	plot_est_time figc2_log_base_future_rd_time "Discontinuity in Log Base Pay 18 Months After Hire" 
	plot_est_time figc2_wage_growth_rd_time "Discontinuity in % Change in Base Pay 18 Months After Hire" 
	plot_est_time figc2_separation_rd_time "Discontinuity in Probability of Separation 18 Months After Hire" 
	
log close